package component

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commRedisRpc"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Json"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Uuid"
)

type extentConfig struct {
}

func (e *extentConfig) Instance() {
	body := `
	{
		"extendType": "DeviceEntityGlobe",
		"extendName": "thingspanel",
		"extendParam": {
			"binds": [],
			"fields": [{
				"dataType": "String",
				"defaultValue": "",
				"fieldName": "thingspanelDeviceNumber"
			}]
		}
	}
	`

	uuid := Uuid.RandomUUID()
	url := "/kernel/manager/extend/entity"
	method := "POST"
	data := Json.BuildMapByJson(body)
	err := commRedisRpc.Manager.Client.Request.PushRequest(uuid, url, method, data)
	if err != nil {
		return
	}

	// 等待响应
	_, err = commRedisRpc.Manager.Client.Respond.Pop(uuid, 1000)
	if err != nil {
		return
	}
}
